package com.zmn.plat.common.dictionary;

import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.zmn.common.dictionary.DictModel;
import com.zmn.common.dto.VtDTO;
import com.zmn.plat.common.constant.PushConsts;
import org.apache.commons.collections.CollectionUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 描述:push 字典类
 *
 * @author wangjie
 * @since 2020/3/21
 **/
public class PushDict {

    /**
     * 描述: vtDtoList to Maps
     *
     * @param var VtDto list
     * @return java.util.Map<java.lang.Integer, java.lang.String>
     * @author wangjie
     * @since 16:56 2019/6/6
     **/
    public static Map<Integer, String> vtDtoToMap(List<VtDTO> var) {

        if (CollectionUtils.isEmpty(var)) {
            return Maps.newHashMap();
        }
        return var
                .stream()
                .collect(Collectors.toMap(VtDTO::getValue, VtDTO::getText));
    }

    /**
     * 描述: dictModel to Maps
     *
     * @param var VtDto list
     * @return java.util.Map<java.lang.Integer, java.lang.String>
     * @author wangjie
     * @since 16:56 2019/6/6
     **/
    public static Map<Integer, String> dictModelToMap(List<DictModel> var) {

        if (CollectionUtils.isEmpty(var)) {
            return Maps.newHashMap();
        }
        return var
                .stream()
                .collect(Collectors.toMap(DictModel::getKey, DictModel::getValue));
    }

    /**
     * 描述: 投放APP 字典
     *
     * @return java.util.List<com.zmn.common.dto.VtDTO>
     * @author wangjie
     * @since 2020/3/21
     **/
    public static List<VtDTO> listPushApp() {
        ArrayList<VtDTO> resultVtDto = Lists.newArrayListWithExpectedSize(8);
        resultVtDto.add(new VtDTO(PushConsts.ZMN_APP_ANDROID, PushConsts.ZMN_APP_ANDROID_STR));
        resultVtDto.add(new VtDTO(PushConsts.ZMN_APP_IOS, PushConsts.ZMN_APP_IOS_STR));
        resultVtDto.add(new VtDTO(PushConsts.YEYX_APP_ANDROID, PushConsts.YEYX_APP_ANDROID_STR));
        resultVtDto.add(new VtDTO(PushConsts.YEYX_APP_IOS, PushConsts.YEYX_APP_IOS_STR));
        resultVtDto.add(new VtDTO(PushConsts.CNHB_APP_ANDROID, PushConsts.CNHB_APP_ANDROID_STR));
        resultVtDto.add(new VtDTO(PushConsts.CNHB_APP_IOS, PushConsts.CNHB_APP_IOS_STR));
        resultVtDto.add(new VtDTO(PushConsts.SAAS_APP_ANDROID, PushConsts.SAAS_APP_ANDROID_STR));
        resultVtDto.add(new VtDTO(PushConsts.SAAS_APP_IOS, PushConsts.SAAS_APP_IOS_STR));
        return resultVtDto;
    }

    /**
     * 描述: 公告分类字典
     *
     * @return java.util.List<com.zmn.common.dto.VtDTO>
     * @author wangjie
     * @since 2020/3/21
     **/
    public static List<VtDTO> listPushNoticeCategory() {

        ArrayList<VtDTO> resultVtDto = Lists.newArrayListWithExpectedSize(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_CONTRACT);
        resultVtDto.add(new VtDTO(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT, PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_STR));
        resultVtDto.add(new VtDTO(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_MARKETING, PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_MARKETING_STR));
        resultVtDto.add(new VtDTO(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_BUSINESS_PROCESS, PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_BUSINESS_PROCESSS_STR));
        resultVtDto.add(new VtDTO(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_SERVICE_PRODUCT, PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_SERVICE_PRODUCT_STR));
        resultVtDto.add(new VtDTO(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_RULES, PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_RULES_STR));
        resultVtDto.add(new VtDTO(PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_CONTRACT, PushConsts.NOTICE_CATEGORY_ANNOUNCEMENT_CONTRACT_STR));
        return resultVtDto;
    }

    /**
     * 描述: 公告分类字典
     *
     * @return java.util.List<com.zmn.common.dto.VtDTO>
     * @author wangjie
     * @since 2020/3/21
     **/
    public static List<VtDTO> listPushType() {

        ArrayList<VtDTO> resultVtDto = Lists.newArrayListWithExpectedSize(PushConsts.PUT_TYPE_PUSH_MSG);
        resultVtDto.add(new VtDTO(PushConsts.PUT_TYPE_START_PAGE, PushConsts.PUT_TYPE_START_PAGE_STR));
        resultVtDto.add(new VtDTO(PushConsts.PUT_TYPE_HOMEPAGE, PushConsts.PUT_TYPE_HOMEPAGE_STR));
        resultVtDto.add(new VtDTO(PushConsts.PUT_TYPE_PUSH_MSG, PushConsts.PUT_TYPE_PUSH_MSG_STR));
        return resultVtDto;
    }

    /**
     * 描述:显示时常字典
     *
     * @return java.util.List<com.zmn.common.dto.VtDTO>
     * @author wangjie
     * @since 2020/3/23
     **/
    public static List<VtDTO> listShowTime() {
        ArrayList<VtDTO> resultVtDto = Lists.newArrayListWithExpectedSize(PushConsts.SHOW_TIME_FIVE);
        resultVtDto.add(new VtDTO(PushConsts.SHOW_TIME_ONE, PushConsts.SHOW_TIME_ONE_STR));
        resultVtDto.add(new VtDTO(PushConsts.SHOW_TIME_TWO, PushConsts.SHOW_TIME_TWO_STR));
        resultVtDto.add(new VtDTO(PushConsts.SHOW_TIME_THREE, PushConsts.SHOW_TIME_THREE_STR));
        resultVtDto.add(new VtDTO(PushConsts.SHOW_TIME_FOUR, PushConsts.SHOW_TIME_FOUR_STR));
        resultVtDto.add(new VtDTO(PushConsts.SHOW_TIME_FIVE, PushConsts.SHOW_TIME_FIVE_STR));
        return resultVtDto;
    }

}
